#include <stdio.h>
#include <stdlib.h>

typedef struct Student
{
	int iId;
	char caName[32];
	float fScore;
}STU;

void input(STU *stu, int count)
{
	int i = 0;
	for (; i<count; i++)
	{
		printf("请输入学生的信息id,name,score:\n");
		scanf("%d%s%f", &stu[i].iId, stu[i].caName
					  , &stu[i].fScore);
	}
}

void display(const STU *stu, int count)
{
	int i = 0;
	for (; i<count; i++)
	{
		printf("id:%d,name:%s,score:%.1f\n"
        	   , stu[i].iId, stu[i].caName
	       	   , stu[i].fScore);
	}
}

STU *findMax(STU *stu, int count)
{
	int i = 0;
	int max = 0;
	for (i=1; i<count; i++)
	{
		if (stu[max].fScore < stu[i].fScore)
		{
			max = i;
		}
	}
	return stu+max;
}

int main(void)
{
	STU *stu = (STU *)malloc(5*sizeof(STU));
	input(stu, 5);
	display(stu, 5);
	printf("--------------------\n\n");
	STU *ret = findMax(stu, 5);
	printf("id:%d,name:%s,score:%.1f\n"
           , ret->iId, ret->caName
	       , ret->fScore);

	free(stu);

	return 0;
}
